import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  // {
  //   title: 'code',
  //   align: "center",
  //   dataIndex: 'code'
  // },
  {
    title: '标题',
    align: "center",
    dataIndex: 'title'
  },
  {
    title: '标题图',
    align: "center",
    dataIndex: 'pic',
    customRender: render.renderImage,
  },
  {
    title: '内容图片',
    align: "center",
    dataIndex: 'contentPic',
    customRender: render.renderImage,
  },
  {
    title: '排序',
    align: "center",
    dataIndex: 'sort'
  },
  {
    title: '是否有效',
    align: "center",
    dataIndex: 'status_dictText'
  },
  {
    title: '是否置顶',
    align: "center",
    dataIndex: 'isTop_dictText'
  },
  {
    title: '阅读量',
    align: "center",
    dataIndex: 'reading'
  },
  {
    title: '收藏',
    align: "center",
    dataIndex: 'following'
  },
  {
    title: '创建时间',
    align: "center",
    dataIndex: 'createTime'
  },
  {
    title: '更新时间',
    align: "center",
    dataIndex: 'updateTime'
  },
  {
    title: '创建人',
    align: "center",
    dataIndex: 'createBy'
  },
  {
    title: '更新人',
    align: "center",
    dataIndex: 'updateBy'
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
];
//表单数据
export const formSchema: FormSchema[] = [
  // {
  //   label: 'code',
  //   field: 'code',
  //   component: 'Input',
  //   dynamicRules: ({model,schema}) => {
  //         return [
  //                { required: true, message: '请输入code!'},
  //         ];
  //    },
  // },
  {
    label: '标题',
    field: 'title',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入标题!' },
      ];
    },
  },
  {
    label: '标题图',
    field: 'pic',
    component: 'JImageUpload',
    componentProps: {
      fileMax: 1
    },
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入标题图!' },
      ];
    },
  },
  {
    label: '内容',
    field: 'content',
    component: 'JEditor',
  },
  {
    label: '内容图片',
    field: 'contentPic',
    component: 'JImageUpload',
    componentProps: {
      fileMax: 9
    },
  },
  {
    label: '排序',
    field: 'sort',
    component: 'InputNumber',
    defaultValue: 0,
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入排序!' },
      ];
    },
  },
  {
    label: '是否有效',
    field: 'status',
    component: 'JDictSelectTag',
    show: false,
    defaultValue: "1",
    // componentProps: {
    //   dictCode: "valid_status"
    // },
    // dynamicRules: ({ model, schema }) => {
    //   return [
    //     { required: true, message: '请输入是否有效!' },
    //   ];
    // },
  },
  {
    label: '是否置顶',
    field: 'isTop',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "nurse_is_top"
    },
  },
  {
    label: '阅读量',
    field: 'reading',
    component: 'InputNumber',
  },
  {
    label: '收藏',
    field: 'following',
    component: 'InputNumber',
  },
  // {
  //   label: '创建时间',
  //   field: 'createTime',
  //   component: 'DatePicker',
  //   componentProps: {
  //     showTime: true,
  //     valueFormat: 'YYYY-MM-DD HH:mm:ss'
  //   },
  //   dynamicRules: ({ model, schema }) => {
  //     return [
  //       { required: true, message: '请输入创建时间!' },
  //     ];
  //   },
  // },
  // {
  //   label: '更新时间',
  //   field: 'updateTime',
  //   component: 'DatePicker',
  //   componentProps: {
  //     showTime: true,
  //     valueFormat: 'YYYY-MM-DD HH:mm:ss'
  //   },
  // },
  {
    label: '创建人',
    field: 'createBy',
    component: 'Input',
    // dynamicRules: ({ model, schema }) => {
    //   return [
    //     { required: true, message: '请输入创建人!' },
    //   ];
    // },
  },
  {
    label: '更新人',
    field: 'updateBy',
    component: 'Input',
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
];

// 高级查询数据
export const superQuerySchema = {
  code: { title: 'code', order: 0, view: 'text', type: 'string', },
  title: { title: '标题', order: 1, view: 'text', type: 'string', },
  pic: { title: '标题图', order: 2, view: 'image', type: 'string', },
  contentPic: { title: '内容图片', order: 4, view: 'image', type: 'string', },
  sort: { title: '排序', order: 5, view: 'number', type: 'number', },
  status: { title: '是否有效', order: 6, view: 'radio', type: 'string', },
  isTop: { title: '是否置顶', order: 7, view: 'radio', type: 'string', },
  reading: { title: '阅读量', order: 8, view: 'number', type: 'number', },
  following: { title: '收藏', order: 9, view: 'number', type: 'number', },
  createTime: { title: '创建时间', order: 10, view: 'datetime', type: 'string', },
  updateTime: { title: '更新时间', order: 11, view: 'datetime', type: 'string', },
  createBy: { title: '创建人', order: 12, view: 'text', type: 'string', },
  updateBy: { title: '更新人', order: 13, view: 'text', type: 'string', },
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}